<template>
	<view class="fund">
		<view class="head" :style="{height: pHeight + tHeight + 'px'}">
			<view class="xztitle" :style="[{height: pHeight + 'px', top: tHeight + 'px',lineHeight: pHeight + 'px'}]">
				提现记录
				<view class="iconfont icon-dayuhao1" @click="fanhui"></view>
			</view>
		</view>
		<view class="headtop clearfix" :style="{marginTop: pHeight + tHeight + 'px'}">
			<view class="top clearfix">
				<view class="right fr clearfix" @click="showstatus = true">
					<view class="name fl">{{sxdate}}</view>
					<u-calendar v-model="showstatus" :mode="mode" toolTip="时间选择" @change="change"></u-calendar>
				</view>
			</view>
		</view>
		<view class="nr" v-if="listData.length != 0">
			<view class="list" v-for="(item,index) in listData" :key="index">
				<view class="liebiao clearfix">
					<view class="left fl">账单号：</view>
					<view class="right fl">
						<view class="title">{{item.danhao}}</view>
					</view>
				</view>
				<view class="liebiao clearfix">
					<view class="left fl">提现方式：</view>
					<view class="right fl">
						<view class="name" v-if="item.pingtai == 0">微信</view>
						<view class="name" v-if="item.pingtai == 1">支付宝</view>
					</view>
				</view>
				<view class="liebiao clearfix" v-if="item.pingtai == 1">
					<view class="left fl">姓名：</view>
					<view class="right fl">
						<view class="title">{{item.name}}</view>
					</view>
				</view>
				<view class="liebiao clearfix">
					<view class="left fl">提现金额：</view>
					<view class="right fl">
						<view class="title">{{item.yuanmoney}}元</view>
					</view>
				</view>
				<view class="liebiao clearfix">
					<view class="left fl">手续费：</view>
					<view class="right fl">
						<view class="title">{{item.shouxufei}}元</view>
					</view>
				</view>
				<view class="liebiao clearfix">
					<view class="left fl">到账金额：</view>
					<view class="right fl">
						<view class="title">{{item.money}}元</view>
					</view>
				</view>
				<view class="liebiao clearfix">
					<view class="left fl">时间：</view>
					<view class="right fl">
						<view class="title">{{item.create_time}}</view>
					</view>
				</view>
				<view class="zhuangtai" v-if="item.status == 4">
					<image :src="baseUrl + '/wximage/failbj.png'"></image>
					<view class="names">打款失败</view>
				</view>
				<view class="zhuangtai" v-if="item.status == 1">
					<image :src="baseUrl + '/wximage/successbj.png'"></image>
					<view class="name">已打款</view>
				</view>
			</view>
		</view>
		<view class="empty" v-else>
			<image :src="baseUrl + '/wximage/empty.png'"></image>
			<text>暂无相关数据</text>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				baseUrl: getApp().globalData.baseUrl,
				headerTop: 0,
				pHeight: 0,
				tHeight: 0,
				showstatus: false,
				mode: 'range',
				sdate: '',
				edate: '',
				sxdate: '筛选',
				listData: [],
				page: 1,
				pageSize: 10,
				total: 0,
			}
		},
		onLoad() {
			// 头部距离
			let res = uni.getSystemInfoSync() ///微信api方法
			let titleH;
			if (res && res['system']) {
				// 判断是否是安卓操作系统 （标题栏苹果为44px,安卓为48px）
				if (res['system'].indexOf('Android') > 0) {
					titleH = 48
				} else {
					titleH = 46
				}
				this.headerTop = titleH + res['statusBarHeight']
				this.pHeight = titleH
				this.tHeight = res['statusBarHeight']
			}
			
			this.getList(this.sdate,this.edate,this.page,this.pageSize);
		},
		onReachBottom() {
			if(this.total != this.listData.length){
				this.page = this.page + 1;
				
				this.getList(this.sdate,this.edate,this.page,this.pageSize);
			}
		},
		methods: {
			getList(sdate,edate,page,pageSize){
				this.request({
					url: '/xcxmoney/cashrecord',
					data: {
						user_id: uni.getStorageSync('user_id'),
						agent_id: uni.getStorageSync('agent_id'),
						page: page,
						pageSize: pageSize,
						sdate: sdate,
						edate: edate,
						role_id: uni.getStorageSync('role_id'),
					},
					method: "POST"
				}).then(res => {
					if (res.data.code == 200) {
						this.total = res.data.data.total;
						this.listData = this.listData.concat(res.data.data.data);
					} else {
						uni.showToast({
							title: '请求失败，请稍后再试',
							icon: 'none'
						})
					}
				})
			},
			change(e) {
				this.sdate = e.startDate;
				this.edate = e.endDate;
				
				this.sxdate = this.sdate + '至' + this.edate;
				
				this.page = 1;
				this.pageSize = 10;
				this.listData = [];
				this.getList(this.sdate,this.edate,this.page,this.pageSize);
			},
			fanhui() {
				uni.navigateBack();
			}
		}
	}
</script>

<style lang="scss">
	page{
		background: #f9f9ff;
	}
	
	.fund {
		width: 100%;
		margin: 0 auto;

		.head {
			width: 100%;
			position: fixed;
			top: 0;
			left: 0;
			z-index: 99;
			background: linear-gradient(90deg, #f9f9ff, #d4e8ff);

			.xztitle {
				position: fixed;
				left: 0%;
				top: 0;
				width: 100%;
				text-align: left;
				color: #333333;
				font-size: 32rpx;
				padding-left: 74rpx;
				font-weight: 700;

				.iconfont {
					position: absolute;
					top: 0;
					left: 30rpx;
					font-size: 44rpx;
				}
			}
		}

		.headtop {
			width: 100%;
			background: linear-gradient(90deg, #f9f9ff, #d4e8ff);
			height: 300rpx;
			padding: 10rpx 40rpx 0;
			box-sizing: border-box;
			
			.right {
				padding: 0 20rpx;
				height: 36rpx;
				line-height: 36rpx;
				text-align: center;
				background: #FFFFFF;
				border-radius: 24rpx;
			
				image {
					width: 36rpx;
					height: 36rpx;
					margin-right: 6rpx;
				}
			
				.name {
					font-size: 24rpx;
					color: #5C88FA;
				}
			}
		}
		
		.nr{
			width: 90%;
			margin: 0 auto;
			z-index: 70;
			margin-top: -220rpx;
			box-shadow: rgba(223, 230, 255, 0.67) 0px 0px 6px;
			
			.list{
				width: 100%;
				background: #fff;
				border-radius: 20rpx;
				margin-bottom: 20rpx;
				padding: 40rpx 40rpx 10rpx;
				position: relative;
				
				.liebiao{
					margin-bottom: 30rpx;
					
					.left{
						font-size: 24rpx;
						color: #333333;
						width: 30%;
					}
					
					.right{
						
						.title{
							font-size: 24rpx;
							color: #333333;
						}
						
						.name{
							font-size: 24rpx;
							color: #5C88FA;
						}
					}
				}
				
				.zhuangtai{
					position: absolute;
					top: 40rpx;
					right: 40rpx;
					
					image{
						width: 100rpx;
						height: 32rpx;
					}
					
					.name{
						width: 100rpx;
						height: 32rpx;
						text-align: center;
						line-height: 32rpx;
						font-size: 20rpx;
						position: absolute;
						top: 0;
						right: 0;
						color: #15827F;
					}
					
					.names{
						width: 100rpx;
						height: 32rpx;
						text-align: center;
						line-height: 32rpx;
						font-size: 20rpx;
						position: absolute;
						top: 0;
						right: 0;
						color: #FA5E5C;
					}
				}
			}
		}
		
		.empty{
			width: 100%;
			margin: -80rpx auto 0;
			text-align: center;
			
			image{
				width: 390rpx;
				height: 340rpx;
			}
			
			text{
				display: block;
				margin-top: 60rpx;
				font-size: 24rpx;
				color: #666666;
			}
		}
	}
</style>